Re: [SQL] quest:optimization with indexes

Поиск
Список
Период
Сортировка
От Herouth Maoz
Тема Re: [SQL] quest:optimization with indexes
Дата
Msg-id l03130302b3d727c777c5@[147.233.159.109]
обсуждение исходный текст
Ответ на quest:optimization with indexes  (Clayton Cottingham <drfrog@smartt.com>)
Ответы Re: [SQL] quest:optimization with indexes  ("Ross J. Reedstrom" <reedstrm@wallace.ece.rice.edu>)
Список pgsql-sql
At 01:42 +0300 on 11/08/1999, Clayton Cottingham wrote:


> if we put in an index or not an explain say it still does a seq scan,
> same amount of time taken!
>
> ive tried putting the index using just the oid , a combo of some fields
> of our data using btree
>
> where/what rules should be followed for setting up a good indexing
> scheme under pg?

You should put indices on the fields mentioned in your query's WHERE clause.

You should try and avoid using functions on the fields in a WHERE clause.
For example, even if you have an index on the field "surname" in your
table, a query with WHERE upper( surname ) = "SMITH" will not use that
index. You can define indices on the function upper(surname) if this sort
of query is common.

The same goes for operators such as LIKE. LIKE will only use the index if
the expression is anchored to the beginning of the string, as in WHERE
surname LIKE 'Smi%', but not WHERE surname LIKE '%mit%'.

And always keep in mind that adding indices penalizes you on insert and update.

Herouth

--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma




В списке pgsql-sql по дате отправления:

Предыдущее
От: Clayton Cottingham
Дата:
Сообщение: quest:text search optimizing ala glimpse
Следующее
От: "Ross J. Reedstrom"
Дата:
Сообщение: Re: [SQL] quest:optimization with indexes